package models.mappers;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import mobile.models.IdentityInfo;
import models.User;
import vos.Page;

/**
 * 认证信息管理
 * @author zhiyuan
 * @version v1.0
 * @since 2016年12月23日 下午4:06:48
 */
public interface IdentityInfoMapper {
	
	@Select("select * from " + IdentityInfo.TABLE_NAME + " where user_id = #{userId}")
	public IdentityInfo selectOneByUserId(Long userId);
	
	public void insert(IdentityInfo identityInfo);
	
	public void update(IdentityInfo identityInfo);
	
	@Select("select count(1) from "  + IdentityInfo.TABLE_NAME + " where user_id = #{userId} and status='PASS'")
	public int isCheckPass(Long userId);
	
	@Update("update " + IdentityInfo.TABLE_NAME + " set status=#{status}, check_user_id = #{checkUserId}, check_time = #{checkTime}, memo=#{memo} where id=#{id}")
	public void check(IdentityInfo identityInfo);
	
	//@Select("select count(1) from " + IdentityInfo.TABLE_NAME + " where status='WAIT_CHECK'")
	public int count(@Param("nick")String nick, @Param("status")String status);
	
//	@Select("select m.*, s.nick from user_identity_info m left join user s on s.id = m.user_id limit #{startIndex},#{pageSize}")
	List<IdentityInfo> listByPage(@Param("p")Page p, @Param("nick")String nick, @Param("status")String status);
	
}
